{{include file="Manage/header.html"}}
<body>
{{include file="Manage/menu.html"}}
	<div class="edit_pro">
		<div class="bule_bg"></div>	
			<!--内容 S-->
			<form method="post" onsubmit="return false" action="index.php?app=Role&act=file">
				<div class="content">
	                <div class="upload_file">
	                    <div class="title">上传表格</div>
	                    <div class="basic_infor">
			                <p>请先<a href="{{$smarty.const.__PUB__}}share/images/download_file/rolemanage.xlsx">下载excel例子模板<img src="{{$smarty.const.__APP__}}manage/images/excel.png"></a>编辑后上传文件，并修改文件名</p>
		                </div>
		                <div class="pro_intro">
		                    <a  href="javascript:" class="sim_file">
		                        {{if $project.files}}重新上传{{else}}上传文件{{/if}}
		                        <input type="file" name="upload" placeholder="请选择上传文件" id="upload" value="{{$project.files}}"></a>
		                    <span class="showFileName1">{{if $project.files}}{{$project.project}}{{else}}未上传文件{{/if}}</span>     	
		                    <p class="notes">格式为xls、xlsx，不超过2M，文件数量限一个。</p>
						</div>
		                <input type="hidden" name="files" id="files" value="{{$project.files}}">
		                <button onclick="importExp();" class="button">确定插入</button>
		                <a href="index.php?app=Role&act=manage">返回</a>
	                </div>
                </div>
	 		</form>
	 	</div>
	</div>
	<script type="text/javascript">

		$("#upload").change(function(){
	        $("form").ajaxSubmit({
	            dataType:  'json',
	            success: function(result) {
	                if(result.statusCode == '200'){
	                    $("input[name=files]").val(result.message);
	                    $(".sim_file").html('已上传');
	                    $(".showFileName1").html(result.data);
	                }
	                else if(result.statusCode == '300'){
	                    $("input[name=files]").val("{{$project.files}}");
	//                    $("#pic").attr('src',"{{$result.image|photo}}");
	                    $(".showFileName1").html(result.message);
	                    ui.error(result.message);
	                }
	            }
	        });
	    });


		function importExp(){
			var name = $("#files").val();
            $.post('{{"index.php?app=Role&act=readexcel"|URL}}',{'name':name},function(result){
	            if(result.statusCode=='200'){
	                ui.success(result.message);
	                setTimeout(function(){
	                    var url = "{{$smarty.const.__PROJECT__}}Role/manage";
	                    document.location.href = url;//登录后跳转页面
	                },1000);
            	}else if(result.statusCode=='300') ui.error(result.message);
        	},'json');
		}
	</script>
	{{include file="Manage/footer.html"}}